﻿using System;
using System.Windows;
using System.Windows.Input;

namespace CanTIceCream
{
    /// <summary>
    /// Window1.xaml 的交互逻辑
    /// </summary>
    public partial class Window1 : Window
    {
        public Window1()
        {
            InitializeComponent();
        }

        private void exit_MouseDown(object sender, MouseButtonEventArgs e)
        {
            this.Close();
        }

        private void boluo1_MouseDown(object sender, MouseButtonEventArgs e)
        {
            try
            {
                IceMsg.Instance.ClientSend("AA 00 20 00 00 00 08 00 0F 00 01 00 00 00 00 00");
            }
            catch (Exception)
            {
                return;
            }
        }

        private void boluo2_MouseDown(object sender, MouseButtonEventArgs e)
        {
            try
            {
                IceMsg.Instance.ClientSend("AA 00 20 00 00 00 08 00 0F 00 02 00 00 00 00 00");
            }
            catch (Exception)
            {
                return;
            }
        }

        private void boluo3_MouseDown(object sender, MouseButtonEventArgs e)
        {
            try
            {
                IceMsg.Instance.ClientSend("AA 00 20 00 00 00 08 00 0F 00 03 00 00 00 00 00");
            }
            catch (Exception)
            {
                return;
            }
        }

        private void caomei1_MouseDown(object sender, MouseButtonEventArgs e)
        {
            try
            {
                IceMsg.Instance.ClientSend("AA 00 20 00 00 00 08 00 10 00 01 00 00 00 00 00");
            }
            catch (Exception)
            {
                return;
            }
        }

        private void caomei2_MouseDown(object sender, MouseButtonEventArgs e)
        {
            try
            {
                IceMsg.Instance.ClientSend("AA 00 20 00 00 00 08 00 10 00 02 00 00 00 00 00");
            }
            catch (Exception)
            {
                return;
            }
        }

        private void caomei3_MouseDown(object sender, MouseButtonEventArgs e)
        {
            try
            {
                IceMsg.Instance.ClientSend("AA 00 20 00 00 00 08 00 10 00 03 00 00 00 00 00");
            }
            catch (Exception)
            {
                return;
            }
        }

        private void qiaokeli1_MouseDown(object sender, MouseButtonEventArgs e)
        {
            try
            {
                IceMsg.Instance.ClientSend("AA 00 20 00 00 00 08 00 11 00 01 00 00 00 00 00");
            }
            catch (Exception)
            {
                return;
            }
        }

        private void qkl2_MouseDown(object sender, MouseButtonEventArgs e)
        {
            try
            {
                IceMsg.Instance.ClientSend("AA 00 20 00 00 00 08 00 11 00 02 00 00 00 00 00");
            }
            catch (Exception)
            {
                return;
            }
        }

        private void qkl3_MouseDown(object sender, MouseButtonEventArgs e)
        {
            try
            {
                IceMsg.Instance.ClientSend("AA 00 20 00 00 00 08 00 11 00 03 00 00 00 00 00");
            }
            catch (Exception)
            {
                return;
            }
        }

        private void bingqltime_MouseDown(object sender, MouseButtonEventArgs e)
        {
            try
            {
                var dd = STime1.Text;
                IceMsg.Instance.ClientSend("AA 00 21 00 00 00 04 00 0A 00 " + dd + " 00");
                MessageBox.Show("设置成功！");
            }
            catch (Exception)
            {
                return;
            }
        }

        private void gstime1_MouseDown(object sender, MouseButtonEventArgs e)
        {
            try
            {
                var dd = GSTime1.Text;
                string sj1 = "";
                string sj2 = "";
                var ss = (int.TryParse(dd, out int ss1) ? ss1 : 00) / 100;
                if (ss < 10)
                    sj1 = "0" + ss;
                else
                    sj1 = ss.ToString();
                int hh = (int.TryParse(dd, out int ss2) ? ss2 : 00) % 100;
                if (hh < 10)
                    sj2 = "0" + hh;
                else
                    sj2 = hh.ToString();
                IceMsg.Instance.ClientSend("AA 00 21 00 00 00 04 00 05 00 " + sj2 + " " + sj1);
                MessageBox.Show("设置成功！");
            }
            catch (Exception)
            {
                return;
            }
        }

        private void gstime2_MouseDown(object sender, MouseButtonEventArgs e)
        {
            try
            {
                var dd = GSTime1.Text;
                string sj1 = "";
                string sj2 = "";
                var ss = (int.TryParse(dd, out int ss1) ? ss1 : 00) / 100;
                if (ss < 10)
                    sj1 = "0" + ss;
                else
                    sj1 = ss.ToString();
                int hh = (int.TryParse(dd, out int ss2) ? ss2 : 00) % 100;
                if (hh < 10)
                    sj2 = "0" + hh;
                else
                    sj2 = hh.ToString();
                IceMsg.Instance.ClientSend("AA 00 21 00 00 00 04 00 06 00 " + sj2 + " " + sj1);
                MessageBox.Show("设置成功！");
            }
            catch (Exception)
            {
                return;
            }
        }

        private void GJtime1_MouseDown(object sender, MouseButtonEventArgs e)
        {
            try
            {
                var dd = GJTime1.Text;
                string sj1 = "";
                string sj2 = "";
                var ss = (int.TryParse(dd, out int ss1) ? ss1 : 00) / 100;
                if (ss < 10)
                    sj1 = "0" + ss;
                else
                    sj1 = ss.ToString();
                int hh = (int.TryParse(dd, out int ss2) ? ss2 : 00) % 100;
                if (hh < 10)
                    sj2 = "0" + hh;
                else
                    sj2 = hh.ToString();
                IceMsg.Instance.ClientSend("AA 00 21 00 00 00 04 00 02 00 " + sj2 + " " + sj1);
                MessageBox.Show("设置成功！");
            }
            catch (Exception)
            {
                return;
            }
        }

        private void GJtime2_MouseDown(object sender, MouseButtonEventArgs e)
        {
            try
            {
                var dd = GJTime2.Text;
                string sj1 = "";
                string sj2 = "";
                var ss = (int.TryParse(dd, out int ss1) ? ss1 : 00) / 100;
                if (ss < 10)
                    sj1 = "0" + ss;
                else
                    sj1 = ss.ToString();
                int hh = (int.TryParse(dd, out int ss2) ? ss2 : 00) % 100;
                if (hh < 10)
                    sj2 = "0" + hh;
                else
                    sj2 = hh.ToString();
                IceMsg.Instance.ClientSend("AA 00 21 00 00 00 04 00 03 00 " + sj2 + " " + sj1);
                MessageBox.Show("设置成功！");
            }
            catch (Exception)
            {
                return;
            }
        }

        private void GJtime3_MouseDown(object sender, MouseButtonEventArgs e)
        {
            try
            {
                var dd = GJTime3.Text;
                string sj1 = "";
                string sj2 = "";
                var ss = (int.TryParse(dd, out int ss1) ? ss1 : 00) / 100;
                if (ss < 10)
                    sj1 = "0" + ss;
                else
                    sj1 = ss.ToString();
                int hh = (int.TryParse(dd, out int ss2) ? ss2 : 00) % 100;
                if (hh < 10)
                    sj2 = "0" + hh;
                else
                    sj2 = hh.ToString();
                IceMsg.Instance.ClientSend("AA 00 21 00 00 00 04 00 04 00 " + sj2 + " " + sj1);
                MessageBox.Show("设置成功！");
            }
            catch (Exception)
            {
                return;
            }
        }
    }
}
